<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=UTF-8" %>
<%@ include file="/resources/modular/plugin/taglibs.jsp" %>
<!doctype html>
<head content="-系统用户管理">
    <%@ include file="/resources/modular/head/inside_factory_head.jsp" %>
    <style type="text/css">
        .pointpage_psddv, .pointpage_psdpoint, .pointpage_dv {
            display: none;
        }

        .my_childAccount_pointpagedv_ul ul {
            display: none;
        }

        .my_childAccount_pointpagedv_ul > li > p, .my_childAccount_pointpagedv_rightul > li > p {
            text-indent: 20px;
            line-height: 40px;
            color: #666;
            border-bottom: 1px solid #eee;
        }

        .my_childAccount_addBtn, .my_childAccount_removeBtn {
            display: none;
            font-style: normal;
        }

        .my_childAccount_pointpagedv_left .my_childAccount_removeBtn {
            display: inline;
            color: #f00;
            font-size: 14px;
        }

        .my_childAccount_pointpagedv_right .my_childAccount_addBtn {
            display: inline;
            color: #38adff;
            font-size: 14px;
        }
    </style>
</head>
<body class="GC_Menu_3" name="GC_systemuser">
<%@ include file="/resources/modular/plugin/mainFactoryMenu.jsp" %>
<div class="loading"></div>
<div class="page" name="GC_systemuser">

    <%@ include file="/resources/modular/plugin/mainFactoryTopMenu.jsp" %>
    <%@ include file="/resources/modular/plugin/usersmanageMeun.jsp" %>
    <div class="page_line"></div>

    <div class="page_right userspage_right">
        <div class="users_system_pointdv">
            <p>* 系统初始密码默认为：123456</p>
            <p>* 修改密码，若不需要设置新密码，可直接恢复初始密码</p>
        </div>

        <p class="users_addrole_pointpagep1">角色名称：
            <input id="GC_addusergroup_rolename" type="text" placeholder="请输入需要添加的角色名称">
        </p>

        <!-- 授权管理 -->
        <div class="users_system_pointpage" style="background:#FFF;">
            <div class="my_childAccount_pointpagedv">
                <div class="my_childAccount_pointpagedv_left">
                    <p class="my_childAccount_pointpagep2">已选授权名称</p>
                    <ul class="my_childAccount_pointpagedv_ul" id="GC_MODULE_USEDMODULE">
                        <%--动态追加内容--%>
                    </ul>
                </div>

                <div class="my_childAccount_pointpagedv_right">
                    <p class="my_childAccount_pointpagep2">可选授权名称</p>
                    <ul class="my_childAccount_pointpagedv_ul">
                        <%--一级目录 开始--%>
                        <c:forEach items="${modules}" var="module" varStatus="perentStatus">
                            <li>
                                <p class="my_childAccountId_${perentStatus.index}">
                                    <span class="my_childAccount_name"
                                          GC_ROLEMODULE="${module.id}">${module.text}（可选择）</span>
                                    <a href="javascript:;"><var class="my_childAccount_addBtn">全部添加</var><var
                                            class="my_childAccount_removeBtn">全部删除</var></a>
                                </p>
                                <ul class="">
                                        <%--二级目录 开始--%>
                                    <c:forEach items="${module.children}" var="levelChildren2"
                                               varStatus="levelChildren2Status">
                                        <li>
                                            <p class="my_childAccountId_${perentStatus.index}_${levelChildren2Status.index}"><span
                                                    class="my_childAccount_name"
                                                    GC_ROLEMODULE="${levelChildren2.id}">${levelChildren2.text}</span><a
                                                    href="javascript:;"><var
                                                    class="my_childAccount_removeBtn">删除</var><var
                                                    class="my_childAccount_addBtn">添加</var></a></p>
                                            <ul class="">
                                                    <%--三级目录 开始--%>
                                                <c:forEach items="${levelChildren2.children}" var="levelChildren3"
                                                           varStatus="levelChildren3Status">
                                                    <li>
                                                        <p class="my_childAccountId_${perentStatus.index}_${levelChildren2Status.index}_${levelChildren3Status.index}"><span
                                                                class="my_childAccount_name"
                                                                GC_ROLEMODULE="${levelChildren3.id}">${levelChildren3.text}</span><a
                                                                href="javascript:;"><var
                                                                class="my_childAccount_removeBtn">删除</var><var
                                                                class="my_childAccount_addBtn">添加</var></a></p>
                                                        <ul class="">

                                                            <c:forEach items="${levelChildren3.children}"
                                                                       var="levelChildren4"
                                                                       varStatus="levelChildren4Status">
                                                                <li>
                                                                    <p class="my_childAccountId_${perentStatus.index}_${levelChildren2Status.index}_${levelChildren3Status.index}_${levelChildren4Status.index}">
                                                                        <span GC_ROLEMODULE="${levelChildren4.id}">${levelChildren4.text}</span><a
                                                                            href="javascript:;"><var
                                                                            class="my_childAccount_removeBtn">删除</var><var
                                                                            class="my_childAccount_addBtn">添加</var></a>
                                                                    </p></li>
                                                            </c:forEach>
                                                        </ul>
                                                    </li>
                                                </c:forEach>
                                                    <%--三级目录 结束--%>
                                            </ul>
                                        </li>
                                    </c:forEach>
                                        <%--二级目录 结束--%>
                                </ul>
                            </li>

                        </c:forEach>
                        <%--一级目录 结束--%>
                    </ul>
                </div>

            </div>
            <p class="users_system_pointpagep3">
                <a class="users_addrole_addchildbtn1" href="javascript:;">确认</a>
                <a class="users_addrole_addchildbtn2" href="javascript:;">取消</a></p>
        </div>
        <!-- 授权管理 end -->

    </div>
</div>
</body>
</html>
<%@ include file="/resources/modular/foot/inside_factory_footer.jsp" %>
<script type="text/javascript" src="${basePath}resources/js/v2/factory/improve.js"></script>
<script type="application/javascript">

    <%-- 新增子角色 --%>
    $(".users_addrole_addchildbtn1").click(function () {

        var rolename = $("#GC_addusergroup_rolename").val();
        if (typeof(rolename) == "undefined" || rolename.length <= 0) {
            alert("角色名称不能为空");
        } else {
            var modulesArray = new Array();

            $("#GC_MODULE_USEDMODULE span").each(function (index, obj) {
                modulesArray[index] = $(obj).attr("GC_ROLEMODULE");
            })

            console.info(modulesArray);

            $.ajax({
                url: '${basePath}v2/factory/individual/addsystemrole',
                type: 'POST',
                data: {
                    "rolename": rolename,
                    "roleType": 3,
                    "modules":modulesArray
                },
                traditional: true,
                error: function (response) {
                    $errorMsg(response);
                },
                success: function (ret) {
                    if (ret.result) {
                        alert("添加角色成功", "cur");
                        window.location.href = document.referrer;
                    } else {
                        alert(ret.info);
                    }
                }
            });
        }
    });

</script>